$(function() {
	
	$(document).on("blur","#oldPassword",function(){
		oldpass();
	});
	$(document).on("blur","#password",function(){
		newpass();
	});
	$(document).on("blur","#passwordConfirm",function(){
		connewpass();
	});
	$(document).on("submit","#systemAccount",function(){
		if(oldpass() && newpass() && connewpass()){
			return true;
		}
		return false;
	});
});
function oldpass(){
	var ok = false;
	var cellpass = $("#oldPassword").val().trim();
	if(cellpass == "") {
		$("#oldPassworderr").html("请输入原密码");
		ok = false;
	} else if(cellpass.length<6){
		$("#oldPassworderr").html("原密码长度不能小于6位");
		ok = false;
	}else{
		$("#oldPassworderr").html("");
		$.ajax({
			type: "post", //请求的方式
			url: "/ModifyPass", //请求的路径
			dataType: "html", //返回的数据类型
			data: {oldpass: cellpass}, //要往后台提交的数据 request.getParameter("validate")
			async: false,
			success: function success(data) { //回调方法
				if($.trim(data)!=null && $.trim(data)!=""){
					ok = true;
				}else{
					ok = false;
					$("#oldPassworderr").html("输入密码与原密码不一致");
				}
			}
		});
	}
	return ok;
}
function newpass(){
	var ok = false;
	var cellpass = $("#password").val().trim();
	if(cellpass == "") {
		$("#passworderr").html("请输入新密码");
		ok = false;
	} else if(cellpass.length<6){
		$("#passworderr").html("新密码长度不能小于6位");
		ok = false;
	}else{
		$("#passworderr").html("");
		ok = true;
	}
	return ok;
}
function connewpass(){
	var ok = false;
	var cellpass = $("#password").val().trim();
	var cellpassword = $("#passwordConfirm").val().trim();
	if(cellpassword == "") {
		$("#passwordConfirmerr").html("请输入确认新密码");
		ok = false;
	} else if(cellpassword.length < 6){
		$("#passwordConfirmerr").html("确认新密码长度不能小于6位");
		ok = false;
	}else if(cellpass != cellpassword) {
		$("#passwordConfirmerr").html("新密码和确认新密码不一致");
		ok = false;
	} else {
		$("#passwordConfirmerr").html("");
		ok = true;
	}
	return ok;
}